package cn.itrip.biz.controller;
import cn.itrip.beans.dtos.Dto;
import cn.itrip.beans.vo.ItripLabelDicVO;
import cn.itrip.beans.vo.SearchHotelRoomVO;
import cn.itrip.biz.service.HotelRoomService;
import cn.itrip.biz.service.ItripLabelDicService;
import cn.itrip.common.DtoUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.*;

@RestController
@RequestMapping("/api/hotelroom")
public class HotelRoomController {
    @Resource
    private HotelRoomService hotelRoomService;
    @Resource
    private ItripLabelDicService itripLabelDicService;
    @ApiOperation(value = "查询酒店房间列表", httpMethod = "POST",
            response = Dto.class, notes = "查询酒店房间列表" +
            "<p>成功：success = ‘true’ | 失败：success = ‘false’ 并返回错误码，如下：</p>" +
            "<p>错误码：</p>" +
            "<p>100303 : 酒店id不能为空,酒店入住及退房时间不能为空,入住时间不能大于退房时间</p>" +
            "<p>100304 : 系统异常</p>")
    @RequestMapping(value = "/queryhotelroombyhotel")
    @ResponseBody
    public Dto queryHotelRoomByHotel(@RequestBody SearchHotelRoomVO vo) {
             List<List<SearchHotelRoomVO>> hotelRoomVOList = null;
             try{
                 List<SearchHotelRoomVO> originalRoomList = hotelRoomService.getItripHotelRoomListByMap(vo);
                 hotelRoomVOList = new ArrayList();
                 for (SearchHotelRoomVO roomVO : originalRoomList) {
                     List<SearchHotelRoomVO> tempList = new ArrayList<SearchHotelRoomVO>();
                     tempList.add(roomVO);
                     hotelRoomVOList.add(tempList);
                 }
                 return DtoUtils.returnSuccess("获取成功", hotelRoomVOList);

             } catch (Exception e) {
                 e.printStackTrace();
                 return DtoUtils.returnFail("获取列表失败", "100305");
             }

    }
    @ApiOperation(value = "查询酒店房间床型列表", httpMethod = "GET",
            protocols = "HTTP", produces = "application/json",
            response = Dto.class, notes = "查询酒店床型列表" +
            "<p>成功：success = ‘true’ | 失败：success = ‘false’ 并返回错误码，如下：</p>" +
            "<p>错误码：</p>" +
            "<p>100305 : 获取酒店房间床型失败</p>")
    @RequestMapping(value = "/queryhotelroombed", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public Dto queryHotelRoomBed() {
            List<ItripLabelDicVO> itripLabelDicList = itripLabelDicService.getItripLabelDicByParentId(1L);
            return DtoUtils.returnSuccess("获取成功", itripLabelDicList);

    }
}
